package cate.game.role.pvp.pointrace.msg;

import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBPointRace;
import cate.game.pvp.pointrace.data.PointRaceOpponent;
import easy.java.practice.errorcode.EcResult;

import java.util.List;

@ClientMsg(title = "获取挑战对手 の 请求")
public class PointRaceOpponentListReq implements MsgInput {
    @Override
    public void execute(GameBody game, ClientContext cc) {
        EcResult<List<PointRaceOpponent>> r = game.pvp.pointRace.getHandler()
                .findOpponents(cc.getRole());
        if (r.ok()) {
            cc.sendNow(new PointRaceOpponentListResp(r.data));
        } else {
            game.notice.message(cc.getRole(), r.message);
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBPointRace.OPPONENT_LIST_REQ;
    }
}
